<template>
  <div class="sliderMenu">
     <swiper :options="swiperOption">
        <swiper-slide v-for="(page, index) of pages" :key="index">
          <div class="menu_content" v-for="(item,index) of page" :key="index">
             <div class="menu_pic">
                <img class="swiper-img" :src="item.imgUrl" />
           </div>
          <p class="menu_title">{{item.desc}}</p>
          </div>
        </swiper-slide>
        <div class="swiper-pagination" slot="pagination"></div>
      </swiper>

  </div>
</template>

<script>
import { swiper, swiperSlide } from "vue-awesome-swiper";
export default {
  name: "sliderMenu",
  props: {
    list: {
      type: Array,
      default() {
        return [];
      }
    }
  },

  data() {
    return {
      swiperOption: {
        autoplay: false,
        loop: false,
        pagination: {
          el: ".swiper-pagination"
        }
      }
    };
  },
  computed: {
    pages() {
      const pages = [];
      this.list.forEach((item, index) => {
        const page = Math.floor(index / 8);
        if (!pages[page]) {
          pages[page] = [];
        }
        pages[page].push(item);
      });
      return pages;
    }
  }
};
</script>
<style lang="stylus" scoped>
.sliderMenu >>> .swiper-pagination-bullet-active {
  background: #fff;
}

.swiper-slide {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
}

.menu_content {
  overflow: hidden;
  width: 25%;
  height: 0;
  padding-bottom: 25%;
  text-align: center;

  .swiper-img {
    width: 80%;
    height: 80%;
    padding: 0.1rem;
    box-sizing: border-box;
  }
}
</style>